package org.boulderfoodrescue.webapp.client.events;

import org.boulderfoodrescue.webapp.shared.OneTimeEvent;

import com.google.gwt.event.shared.GwtEvent;

public class OneTimeEventUpdatedEvent extends GwtEvent<OneTimeEventUpdatedHandler>{
	private static final Type<OneTimeEventUpdatedHandler> TYPE = new Type<OneTimeEventUpdatedHandler>();
	private ChangeType changeType;
	private OneTimeEvent oneTimeEvent;

	public OneTimeEventUpdatedEvent(ChangeType changeType, OneTimeEvent oneTimeEvent) {

		this.changeType = changeType;
		this.oneTimeEvent = oneTimeEvent;
	}

	public static Type<OneTimeEventUpdatedHandler> getType() {
		return TYPE;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<OneTimeEventUpdatedHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(OneTimeEventUpdatedHandler handler) {
		switch(changeType)
		{
		case Added: handler.onOneTimeEventAdded(this);break;
		case Removed: handler.onOneTimeEventRemoved(this);break;
		case Updated: handler.onOneTimeEventUpdated(this);break;
		}
	}

	public OneTimeEvent getValue(){
		return oneTimeEvent;
	}
}
